/**
 * 
 */
package info.niwota.web.proxy;

import jvs.peer.io.ChannelManager;

import org.apache.commons.pool.impl.GenericKeyedObjectPool;

/**
 * @author qiangli
 *
 */
public final class PeerRoute {
	public static PeerRoute instance = new PeerRoute();
	
	public static PeerRoute getInstance() {
		return instance;
	}
	
	private GenericKeyedObjectPool bluenet = new GenericKeyedObjectPool(
			new ServerSocketThreadObjectFactory(ChannelManager.NETWORK_BTSPP), 1);
	
	private GenericKeyedObjectPool jabnet = new GenericKeyedObjectPool(
			new ServerSocketThreadObjectFactory(ChannelManager.NETWORK_XMPP), 1);
	
	public GenericKeyedObjectPool findNetwork(String realm) {
		if (realm != null && realm.equalsIgnoreCase(ChannelManager.NETWORK_BTSPP)) {
			return bluenet;
		} else {
			return jabnet;
		}
	}
	
	public static GenericKeyedObjectPool get(String realm) {
		return getInstance().findNetwork(realm);
	}
}
